<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="base/layout.html">


<!-- start: Content -->
<div layout:fragment="content" class="main ">

    <div class="row">
        <div class="col-lg-12">
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a th:href="@{../infoManage/indexTotal}">主页</a></li>
                <li><i class="fa fa-list-alt"></i><a
                        th:href="@{../practiceManageInfo/queryPracticeManageInfo}">企业实践管理</a></li>
                <li><i class="fa fa-indent"></i>修改企业实践</li>
            </ol>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>修改企业实践</strong></h2>
                </div>
                <div class="panel-body">
                    <form id="modularForm" action="" method="post" enctype="multipart/form-data"
                          class="form-horizontal ">
                        <input id="practiceManageInfoId" type="hidden" name="id" th:value="${practiceManageInfo.id}"/>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="select">学院</label>
                            <div th:if="${session.userInfo.departmentid==11}" class="col-md-2">
                                <select id="selectDepartment" name="departmentid" class="form-control" size="1"
                                        type="isNotSelectNull">
                                </select>
                                <span class="help-block">请选择学院(必填)</span>
                            </div>
                            <div th:if="${session.userInfo.departmentid!=11}" class="col-md-2">
                                <input id="hiddenDepartment" type="hidden" name="departmentid" class="form-control"
                                       th:value="${session.userInfo.departmentid}">
                                <input type="text" class="form-control"
                                       th:value="${session.userInfo.department.department}" readonly>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="date01">计划时间</label>
                            <div class="col-md-4">
                                <div class="input-group date col-sm-6">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control"
                                           name="practicetimeplan" readonly
                                           th:value="${#dates.format(practiceManageInfo.practicetimeplan,'yyyy-MM-dd')}"
                                           required>
                                </div>
                                <span class="help-block">无法修改</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="date01">实际时间</label>
                            <div class="col-md-4">
                                <div class="input-group date col-sm-6">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control date-picker" id="signagreement"
                                           name="practicetimeactual" readonly
                                           th:value="${#dates.format(practiceManageInfo.practicetimeactual,'yyyy-MM-dd')}"
                                           required>
                                </div>
                                <span class="help-block">请输入实际时间(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">基地名称</label>
                            <div class="col-md-2">
                                <input type="text" name="basename" class="form-control"
                                       th:value="${practiceManageInfo.basename}" readonly required>
                                <span class="help-block">无法修改</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">计划人数</label>
                            <div class="col-md-2">
                                <input type="text" name="peoplenumplan" class="form-control" readonly
                                       th:value="${practiceManageInfo.peoplenumplan}" required>
                                <span class="help-block">无法修改</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">实际人数</label>
                            <div class="col-md-2">
                                <input type="text" name="peoplenumactual" class="form-control"
                                       th:value="${practiceManageInfo.peoplenumactual}" required>
                                <span class="help-block">请输入实际人数(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">计划内容</label>
                            <div class="col-md-2">
                                <input type="text" name="contentplan" class="form-control" readonly
                                       th:value="${practiceManageInfo.contentplan}" required>
                                <span class="help-block">无法修改</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">实际内容</label>
                            <div class="col-md-2">
                                <input type="text" name="contentactual" class="form-control"
                                       th:value="${practiceManageInfo.contentactual}" required>
                                <span class="help-block">请输入实际内容(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">计划校内指导教师姓名</label>
                            <div class="col-md-2">
                                <input type="text" name="teachernameplan" class="form-control" readonly
                                       th:value="${practiceManageInfo.teachernameplan}" required>
                                <span class="help-block">无法修改</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">实际校内指导教师姓名</label>
                            <div class="col-md-2">
                                <input type="text" name="teachernameactual" class="form-control"
                                       th:value="${practiceManageInfo.teachernameactual}" required>
                                <span class="help-block">请输入实际校内指导教师姓名(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">实际创业指导教师姓名</label>
                            <div class="col-md-2">
                                <input type="text" name="teachernameactualentrepreneurship" class="form-control"
                                       th:value="${practiceManageInfo.teachernameactualentrepreneurship}" required>
                                <span class="help-block">请输入实际校内指导教师姓名(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="select">专业</label>
                            <div class="col-md-2">
                                <select id="selectMajor" name="majorid" class="form-control" size="1"
                                        type="isNotSelectNull">

                                </select>
                                <span class="help-block">请选择专业(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">年级和班级</label>
                            <div class="col-md-2">
                                <input type="text" name="classes" class="form-control"
                                       th:value="${practiceManageInfo.classes}" required>
                                <span class="help-block">请输入年级和班级(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="select">实习类别</label>
                            <div class="col-md-2">
                                <select id="selectPracticeType" name="practicetypeid" class="form-control" size="1"
                                        type="isNotSelectNull">

                                </select>
                                <span class="help-block">请选择实习类别(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="select">实习性质</label>
                            <div class="col-md-2">
                                <select id="selectPracticeProperty" name="practicepropertyid" class="form-control"
                                        size="1"
                                        type="isNotSelectNull">

                                </select>
                                <span class="help-block">请选择实习性质(必填)</span>
                            </div>
                        </div>
                        <br>
                </div>
                <div class="panel-footer">
                    <button id="submitBtn" type="submit" class="btn btn-sm btn-success"><i
                            class="fa fa-dot-circle-o"></i> 保存
                    </button>
                    <button type="button" class="btn btn-sm btn-success" onclick="history.back()"><i
                            class="fa fa-dot-circle-o"></i> 返回
                    </button>
                </div>
                </form>
            </div>
        </div>


    </div><!--/.row-->
    <script th:inline="javascript" type="text/javascript">
        $(document).ready(function () {
            var userDepartmentId = [[${session.userInfo.departmentid}]]
            if (userDepartmentId == 11) {
                //加载承办部门
                initDepartment();
                //加载专业
                initMajor();
            } else {
                //加载专业
                initMajor();
            }
            //加载实习类别
            initPracticeType();
            //加载实习性质
            initPracticeProperty();
            //加载时间控件
            setDatePicker("#signagreement");
        })

        function initDepartment() {
            //获取学院id
            var departmentid = [[${practiceManageInfo.departmentid}]];
            $.ajax({
                url: '../department/selectDepartmentInfo',
                type: 'get',
                dataType: 'json',
                data: {},
                success: function (data) {
                    //如果学院id是空
                    if (departmentid == undefined || departmentid == null || departmentid == "") {
                        for (var i in data) {
                            $("#selectDepartment").append("<option value=" + data[i].id + ">" + data[i].department + "</option>");
                        }
                    }
                    else {
                        for (var i in data) {
                            if (departmentid == data[i].id) {
                                $("#selectDepartment").append("<option value=" + data[i].id + " selected>" + data[i].department + "</option>");
                            }
                            else {
                                $("#selectDepartment").append("<option value=" + data[i].id + ">" + data[i].department + "</option>");
                            }
                        }
                    }
                }
            })
            $("#selectDepartment").change(function () {
                $("#selectMajor").empty();
                var str = $("#selectDepartment").find("option:selected").val();
                if (str > 9) {
                    $("#selectMajor").empty();
                    $("#selectMajor").append("<option value=0>无</option>");
                 /*   $.ajax({
                        url: '../major/selectMajorInfo',
                        type: 'get',
                        dataType: 'json',
                        data: {},
                        success: function (data) {
                            for (var i in data) {
                                $("#selectMajor").append("<option value=" + data[i].id + ">" + data[i].majorname + "</option>");
                            }
                        }
                    })*/
                } else {
                    $("#selectMajor").append("<option value=-1>请选择</option>");
                    $.ajax({
                        url: '../major/selectMajor',
                        type: 'post',
                        data: {'departmentid': $("select[name='departmentid']").val()},
                        success: function (data) {
                            for (var i in data) {
                                $("#selectMajor").append("<option value=" + data[i].id + ">" + data[i].majorname + "</option>");
                            }
                        }
                    })
                }
            })
        }

        //加载专业
        function initMajor() {
            var t;
            //获取专业id
            var majorid = [[${practiceManageInfo.majorid}]]
            t = setTimeout(function () {
                var userDepartmentid = [[${session.userInfo.departmentid}]]
                var str1 = $("#selectDepartment").find("option:selected").val();
                var str;

                if (userDepartmentid == 11) {
                    if (str1 > 9) {
                        $("#selectMajor").append("<option value=0>无</option>");
                    }
                    str = {'departmentid': $("select[name='departmentid']").val()};
                } else {
                    str = {'departmentid': $("input[name='departmentid']").val()};
                }
                $.ajax({
                    url: '../major/selectMajor',
                    type: 'post',
                    data: str,
                    success: function (data) {
                        for (var i in data) {
                            if (majorid == data[i].id) {
                                $("#selectMajor").append("<option value=" + data[i].id + " selected>" + data[i].majorname + "</option>");
                            } else {
                                $("#selectMajor").append("<option value=" + data[i].id + ">" + data[i].majorname + "</option>");
                            }
                        }
                    }
                })

            }, 100),
                function () {
                    clearTimeout(t);
                }
        }


        //加载实习类别
        function initPracticeType() {
            //获取实习类别id
            var practicetypeid = [[${practiceManageInfo.practicetypeid}]];
            $.ajax({
                url: '../practiceType/selectPracticeTypeInfo',
                type: 'get',
                dataType: 'json',
                data: {},
                success: function (data) {
                    //如果部门id是空
                    if (practicetypeid == undefined || practicetypeid == null || practicetypeid == "") {
                        for (var i in data) {
                            $("#selectPracticeType").append("<option value=" + data[i].id + ">" + data[i].type + "</option>");
                        }
                    }
                    else {
                        for (var i in data) {
                            if (practicetypeid == data[i].id) {
                                $("#selectPracticeType").append("<option value=" + data[i].id + " selected>" + data[i].type + "</option>");
                            }
                            else {
                                $("#selectPracticeType").append("<option value=" + data[i].id + ">" + data[i].type + "</option>");
                            }
                        }
                    }
                }
            })
        }


        //加载实习性质
        function initPracticeProperty() {
            //获取实习性质id
            var practicepropertyid = [[${practiceManageInfo.practicepropertyid}]];
            $.ajax({
                url: '../practiceProperty/selectPracticePropertyInfo',
                type: 'get',
                dataType: 'json',
                data: {},
                success: function (data) {
                    //如果部门id是空
                    if (practicepropertyid == undefined || practicepropertyid == null || practicepropertyid == "") {
                        for (var i in data) {
                            $("#selectPracticeProperty").append("<option value=" + data[i].id + ">" + data[i].property + "</option>");
                        }
                    }
                    else {
                        for (var i in data) {
                            if (practicepropertyid == data[i].id) {
                                $("#selectPracticeProperty").append("<option value=" + data[i].id + " selected>" + data[i].property + "</option>");
                            }
                            else {
                                $("#selectPracticeProperty").append("<option value=" + data[i].id + ">" + data[i].property + "</option>");
                            }
                        }
                    }
                }
            })
        }


        $("#modularForm").validate({

            submitHandler: function (form) {

                $('#modularForm').ajaxSubmit(      //ajax方式提交表单
                    {
                        url: 'practiceManageInfoUpdate',
                        type: 'post',
                        success: function (data) {
                            layer.msg("修改成功");
                            setTimeout(function () {
                                window.location = ("queryPracticeManageInfo")
                            }, 1500);
                        }
                        //clearForm: false,//禁止清楚表单
                        //resetForm: false //禁止重置表单
                    });
            }
        })
    </script>
</div>








